# Maintainer: David Runge <dvzrv@archlinux.org>

_name=django-sekizai
pkgname=python-django-sekizai
pkgver=4.1.0
pkgrel=2
pkgdesc="Django Template Blocks with extra functionality"
arch=(any)
url="https://github.com/django-cms/django-sekizai"
license=(BSD)
depends=(
  python
  python-django
  python-django-classy-tags
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('cc4a3523d9be4d72c6ead38f62f7792c465ff22d784aca6241b297f67907aa6eec82d1195242404598aefd177fd630d694ebf8fd792d5218e5dda2bc2de86dab')
b2sums=('2cf712b78bb78e92b8b0de691e55d95183bfa533c1a0fae739b83427cab5954e0ddc40db5f7c2793f35256bd14f0cd5b0a13ba93acd97f4b80c7843ace396ef7')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl

  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  python tests/settings.py
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
